package com.hzdl.house_mgr.controller;

import com.hzdl.house_mgr.bean.BaseStat;
import com.hzdl.house_mgr.service.AdminService;
import com.hzdl.house_mgr.service.UserService;
import com.hzdl.house_mgr.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("stat")
public class StatisticsPageController {

    @Autowired
    private UserService userServicer;
    @Autowired
    private AdminService adminService;

    @RequestMapping("customerLocation")
    public String customerLocationMgr(){
        return "business/statistics/customerLocationStat";
    }

    @RequestMapping("mouthSole")
    public String mouthSoleMgr(){
        return "business/statistics/mouthSoleStat";
    }

    @RequestMapping("yearSole")
    public String yearSoleMgr(){
        return "business/statistics/yearSoleStat";
    }

    @RequestMapping("customerStatJson")
    @ResponseBody
    public AjaxResult customerStatJson(){
        List<BaseStat> countByAddress = userServicer.getCountByAddress();
        return AjaxResult.ok(countByAddress);
    }

    @RequestMapping("mouthSoleJson")
    @ResponseBody
    public AjaxResult mouthSoleJson(){
        return null;
    }

    @RequestMapping("yearSoleJson")
    @ResponseBody
    public AjaxResult yearSoleJson(String year){
        List<BaseStat> baseStats = adminService.yearSoleJson(year);
        return AjaxResult.ok(baseStats);
    }
}
